package com.vastcom.tyauthcenter.dao;



import com.vastcom.tyauthcenter.model.Roleresource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface RoleResourceDao extends JpaRepository<Roleresource,String> {

    @Query("select r from Roleresource r where r.role=:role ")
    List<Roleresource> getRoleResourcesByRole(@Param("role") String role);

    @Query("select r from Roleresource r where r.role=:role and r.type=:type")
    List<Roleresource> getRoleresourcesByRoleAndType(@Param("role") String role, @Param("type") String type);

    @Query("select r from Roleresource r where r.resource=:resource")
    List<Roleresource> getRoleResourcesByResource(@Param("resource") String resource);


    @Query("select r from Roleresource r where r.resource=:resource and r.role=:role")
    List<Roleresource> getRoleresourcesByResourceAndRole(@Param("resource") String resource, @Param("role") String role);

}
